<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>数量值{{ count }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          @click="isSel = 'all'"
          :class="{ selected: isSel === 'all' }"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          @click="isSel = 'no'"
          :class="{ selected: isSel === 'no' }"
          href="javascript:;"
          >未完成</a
        >
      </li>
      <li>
        <a
          @click="isSel = 'yes'"
          :class="{ selected: isSel === 'yes' }"
          href="javascript:;"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="$emit('clear')">清除已完成</button>
  </footer>
</template>

<script>
export default {
  // 7 父件子传  统计变量
  props: ["arr"],
  // 计算属性 计算剩余的未完成的数量
  computed: {
    count() {
      return this.arr.filter((item) => item.isDone === false).length;
    },
  },
  data() {
    return {
      isSel: "all",
    };
  },
  watch: {
    // 监听器，监听
    isSel() {
      this.$emit("changeevent", this.isSel);
    },
  },
};
</script>